import React, { Component } from 'react'
import  userMenu from "../services/usermenu/Service";
import Menu from '../router/Menu';
import RouterView from "../router";

export default class Main extends Component<any,any> {
    constructor(props:any){
        super(props);
        this.state = {
            list:[],
        }
    }
  async  componentDidMount(){

    let  userinfo  = window.localStorage.getItem("userinfo");
    if(userinfo){
        let    info  =JSON.parse(userinfo);//用户信息
        let  userid  = info.id;//找到用户编号
        let  {data:list} = await  userMenu.query({userid});
        this.setState({
            list
        })

    }else{
        this.props.history.push("/")

    }

    }


  render() {
    return (
      <div>登录以后看到的页面
            <Menu list={this.state.list}></Menu>
            <hr/>
            <RouterView list={this.state.list}></RouterView>
      </div>
    )
  }
}
